

package com.hexinfo.dmpro.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.admin.model.SysDept;
import com.hexinfo.dmpro.admin.service.SysDeptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 部门表
 *
 * @author zhouax
 * @date 2023-08-09 13:42:26
 */
@RestController
@AllArgsConstructor
@RequestMapping("/sysdept" )
@Api(value = "sysdept", tags = "部门表管理")
public class SysDeptController {

    private final  SysDeptService sysDeptService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param sysDept 部门表
     * WrapperEnhancer.like(sysDept); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public ResponseEntity<Object> getSysDeptPage(Page page, SysDept sysDept) {
        return ResponseEntity.ok(sysDeptService.queryList(page,sysDept));
    }


    /**
     * 通过id查询部门表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public ResponseEntity<Object> getById(@PathVariable("id" ) Long id) {
        return ResponseEntity.ok(sysDeptService.getById(id));
    }

    /**
     * 新增部门表
     * @param sysDept 部门表
     * @return R
     */
    @ApiOperation(value = "新增部门表", notes = "新增部门表")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody SysDept sysDept) {
        return ResponseEntity.ok(sysDeptService.save(sysDept));
    }

    /**
     * 修改部门表
     * @param sysDept 部门表
     * @return R
     */
    @ApiOperation(value = "修改部门表", notes = "修改部门表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody SysDept sysDept) {
        return ResponseEntity.ok(sysDeptService.updateById(sysDept));
    }

    /**
     * 通过id删除部门表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除部门表", notes = "通过id删除部门表")
    @DeleteMapping("/{id}" )
    public ResponseEntity<Object> removeById(@PathVariable Long id) {
        return ResponseEntity.ok(sysDeptService.removeById(id));
    }

}
